package cn.gzsf.coolshark.controller;

import cn.gzsf.coolshark.entity.Category;
import cn.gzsf.coolshark.mapper.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/category/")
@RestController
public class CategoryController {
    @Autowired
    private CategoryMapper categoryMapper;

    @RequestMapping("select")
    public List<Category> select(){
        return categoryMapper.select();
    }

    @RequestMapping("delete")
    public void delete(int id){
        categoryMapper.delete(id);
    }

    @RequestMapping("insert")
    public void insert(String name){
        categoryMapper.insert(name);
    }

    @RequestMapping("update")
    public void update(@RequestBody Category category){
        System.out.println(category);
        categoryMapper.update(category);
    }
}
